using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using NetWorkMsg;
using NetMsg.Player;

// 电话、好友
namespace NetMsg.Phone
{
    public class ContactInfo : IUnPackable
    {
        public string Name;
        public long PlayerId;
        public int HeadIndex;
        public bool IsOnline;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out Name);
            UnPackAuxiliary.Read(stream, out ulong var0);
            PlayerId = (long)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            HeadIndex = (int)var1;
            UnPackAuxiliary.Read(stream, out IsOnline);
        }
    }
    
    public enum TrafficRecordType
    {
        // 没有打通
        AccessFailure,
        // 打出
        Sended,
        // 接入
        Recved,
    }
    
    public enum CallerSetup
    {
        AllowAll,
        OnlyContacts,
    }
    
    // 电话模块基本信息
    public struct GetPhoneQ : IServerCallbackable
    {
        
        public uint UnPackableId => 15;
        public uint PackableId => 37;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 37u);
        }
    }
    
    public class GetPhoneP : IUnPackable
    {
        public List<ContactInfo> Contacts;
        public List<PlayerSummary> Blacklist;
        public CallerSetup CallerSetup;
        
        public const uint Sid = 15;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Contacts = new List<ContactInfo>((int)var0);
            for(var i = 0; i < var0; ++i)
            {
                var var1 = new ContactInfo();
                var1.UnPack(stream);
                Contacts.Add(var1);
            }
            UnPackAuxiliary.Read(stream, out uint var2);
            Blacklist = new List<PlayerSummary>((int)var2);
            for(var i = 0; i < var2; ++i)
            {
                var var3 = new PlayerSummary();
                var3.UnPack(stream);
                Blacklist.Add(var3);
            }
            UnPackAuxiliary.Read(stream, out uint var4);
            CallerSetup = (CallerSetup)var4;
        }
    }
    
    // 获取通话记录
    public struct GetPhoneRecordsQ : IServerCallbackable
    {
        public int Offset;
        public int Number;
        public int Time;
        
        public uint UnPackableId => 16;
        public uint PackableId => 38;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 38u);
            PackAuxiliary.Write(stream, (uint)Offset);
            PackAuxiliary.Write(stream, (uint)Number);
            PackAuxiliary.Write(stream, (uint)Time);
        }
    }
    
    public class CallRecordInfo : IUnPackable
    {
        // 通话Id
        public int CallId;
        // (自己)是否是呼叫方
        public bool IsCaller;
        // 对方的姓名
        public string TargetName;
        // 对方的Id
        public long TargetId;
        // 对方的头像
        public int TargetHead;
        public int TimeStamp;
        public int State;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            CallId = (int)var0;
            UnPackAuxiliary.Read(stream, out IsCaller);
            UnPackAuxiliary.Read(stream, out TargetName);
            UnPackAuxiliary.Read(stream, out ulong var1);
            TargetId = (long)var1;
            UnPackAuxiliary.Read(stream, out uint var2);
            TargetHead = (int)var2;
            UnPackAuxiliary.Read(stream, out uint var3);
            TimeStamp = (int)var3;
            UnPackAuxiliary.Read(stream, out uint var4);
            State = (int)var4;
        }
    }
    
    public class GetPhoneRecordsP : IUnPackable
    {
        public List<CallRecordInfo> Records;
        
        public const uint Sid = 16;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Records = new List<CallRecordInfo>((int)var0);
            for(var i = 0; i < var0; ++i)
            {
                var var1 = new CallRecordInfo();
                var1.UnPack(stream);
                Records.Add(var1);
            }
        }
    }
    
    public struct SetCallerSetupQ : IIdPackable
    {
        public CallerSetup CallerSetup;
        
        public uint PackableId => 39;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 39u);
            PackAuxiliary.Write(stream, (uint)CallerSetup);
        }
    }
    
    public struct SetHeadQ : IIdPackable
    {
        public int HeadIndex;
        
        public uint PackableId => 40;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 40u);
            PackAuxiliary.Write(stream, (uint)HeadIndex);
        }
    }
    
    public enum ContactType
    {
        Blacklist,
        Contacts,
    }
    
    public struct DeleteContactQ : IServerCallbackable
    {
        public ContactType ContactType;
        public long PlayerId;
        
        public uint UnPackableId => 17;
        public uint PackableId => 41;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 41u);
            PackAuxiliary.Write(stream, (uint)ContactType);
            PackAuxiliary.Write(stream, (ulong)PlayerId);
        }
    }
    
    public enum DeleteContactR
    {
        Success,
        NotExists,
    }
    
    public struct DeleteContactP : IUnPackable
    {
        public DeleteContactR Result;
        
        public const uint Sid = 17;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Result = (DeleteContactR)var0;
        }
    }
    
    public struct NoticeBeDeleteP : IUnPackable
    {
        public long PlayerId;
        
        public const uint Sid = 18;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out ulong var0);
            PlayerId = (long)var0;
        }
    }
    
    public struct AddBlackListQ : IServerCallbackable
    {
        public long PlayerId;
        
        public uint UnPackableId => 19;
        public uint PackableId => 42;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 42u);
            PackAuxiliary.Write(stream, (ulong)PlayerId);
        }
    }
    
    public enum AddBlackListResult
    {
        Success,
        // 重复添加
        Again,
        // 是好友
        IsFriended,
    }
    
    public struct AddBlackListP : IUnPackable
    {
        public AddBlackListResult Result;
        
        public const uint Sid = 19;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Result = (AddBlackListResult)var0;
        }
    }
    
    public struct AddContactQ : IServerCallbackable
    {
        public long PlayerId;
        
        public uint UnPackableId => 20;
        public uint PackableId => 43;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 43u);
            PackAuxiliary.Write(stream, (ulong)PlayerId);
        }
    }
    
    public enum AddContactR
    {
        // 请求成功
        Success,
        // 自己达到好友数上限
        Limit,
        // 已经是好友了
        Already,
        // 对方在我的黑名单中
        TargetInBlackList,
        // 在对方的黑名单中
        InBlackList,
        // 重复申请
        Again,
        // 对应玩家不存在
        NotExists,
    }
    
    // 好友申请
    public struct AddContactP : IUnPackable
    {
        public AddContactR Result;
        // 生成的邀请Id 成功时才有效
        public int InvitedId;
        
        public const uint Sid = 20;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Result = (AddContactR)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            InvitedId = (int)var1;
        }
    }
    
    // 答复添加好友邀请
    public struct RepAddContactRepQ : IServerCallbackable
    {
        // 邀请Id
        public int InvitedId;
        // 邀请者的Id
        public long PlayerId;
        public bool Accept;
        
        public uint UnPackableId => 21;
        public uint PackableId => 44;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 44u);
            PackAuxiliary.Write(stream, (uint)InvitedId);
            PackAuxiliary.Write(stream, (ulong)PlayerId);
            PackAuxiliary.Write(stream, Accept);
        }
    }
    
    public enum AddContactReqResult
    {
        Success,
        // 自己达到好友上限
        Limit,
        // 已经是好友了
        Already,
        // 对方在我的黑名单中
        TargetInBlackList,
        // 在对方的黑名单中
        InBlackList,
        // 对方达到了好友上限
        TargetFull,
        // 已无效
        Invalid,
    }
    
    // 操作结果
    public struct RepAddContactRepP : IUnPackable
    {
        public AddContactReqResult Result;
        
        public const uint Sid = 21;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Result = (AddContactReqResult)var0;
        }
    }
    
    // 对方对好友申请的答复
    public class NoticeRepAddP : IUnPackable
    {
        // 邀请Id
        public int InvitedId;
        public PlayerSummary Summary;
        public bool Accept;
        
        public const uint Sid = 22;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            InvitedId = (int)var0;
            Summary = new PlayerSummary();
            Summary.UnPack(stream);
            UnPackAuxiliary.Read(stream, out Accept);
        }
    }
    
    public struct CallPlayerQ : IServerCallbackable
    {
        public long PlayerId;
        
        public uint UnPackableId => 23;
        public uint PackableId => 45;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 45u);
            PackAuxiliary.Write(stream, (ulong)PlayerId);
        }
    }
    
    public enum CallPlayerR
    {
        // 已拨通,等待接听
        Success,
        // 不在线
        Offline,
        // 占线
        Busy,
        // 对方在你的黑名单中
        TargetInBlackList,
        // 你在对方的黑名单中
        InBlackList,
        // 对方不接受陌生人电话
        TargetForbidden,
    }
    
    public struct CallPlayerP : IUnPackable
    {
        // 呼叫Id
        public int CallId;
        public CallPlayerR Result;
        
        public const uint Sid = 23;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            CallId = (int)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            Result = (CallPlayerR)var1;
        }
    }
    
    public class NoticeCallP : IUnPackable
    {
        public int CallId;
        public PlayerSummary Summary;
        
        public const uint Sid = 24;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            CallId = (int)var0;
            Summary = new PlayerSummary();
            Summary.UnPack(stream);
        }
    }
    
    public struct ReplyCallQ : IIdPackable
    {
        public int CallId;
        public bool Accept;
        
        public uint PackableId => 46;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 46u);
            PackAuxiliary.Write(stream, (uint)CallId);
            PackAuxiliary.Write(stream, Accept);
        }
    }
    
    public struct NoticeReplyCallP : IUnPackable
    {
        public int CallId;
        public bool Accept;
        
        public const uint Sid = 25;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            CallId = (int)var0;
            UnPackAuxiliary.Read(stream, out Accept);
        }
    }
    
    public struct AskQuestionQ : IIdPackable
    {
        public int QuestionId;
        
        public uint PackableId => 47;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 47u);
            PackAuxiliary.Write(stream, (uint)QuestionId);
        }
    }
    
    public struct NoticeAskQuestionP : IUnPackable
    {
        public int QuestionId;
        
        public const uint Sid = 26;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            QuestionId = (int)var0;
        }
    }
    
    public struct AnswerQuestionQ : IIdPackable
    {
        public int Choose;
        
        public uint PackableId => 48;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 48u);
            PackAuxiliary.Write(stream, (uint)Choose);
        }
    }
    
    public struct NoticeAnswerP : IUnPackable
    {
        public int Choose;
        
        public const uint Sid = 27;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Choose = (int)var0;
        }
    }
    
    public struct BeginSpeakQ : IIdPackable
    {
        
        public uint PackableId => 49;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 49u);
        }
    }
    
    public struct NoticeSpeakP : IUnPackable
    {
        
        public const uint Sid = 28;
        
        public void UnPack(MemoryStream stream)
        {
        }
    }
    
    public class VoiceInfoQ : IIdPackable
    {
        public NetMsgBuffer Info;
        
        public uint PackableId => 50;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 50u);
            PackAuxiliary.Write(stream, Info);
        }
    }
    
    public class NoticeVoiceInfoP : IUnPackable
    {
        public byte[] Info;
        
        public const uint Sid = 29;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out Info);
        }
    }
    
    public struct HangUpQ : IIdPackable
    {
        
        public uint PackableId => 51;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 51u);
        }
    }
    
    public struct NoticeHangUpP : IUnPackable
    {
        
        public const uint Sid = 30;
        
        public void UnPack(MemoryStream stream)
        {
        }
    }
    
    public struct SearchByIdQ : IServerCallbackable
    {
        public long PlayerId;
        
        public uint UnPackableId => 31;
        public uint PackableId => 52;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 52u);
            PackAuxiliary.Write(stream, (ulong)PlayerId);
        }
    }
    
    public class SearchByIdP : IUnPackable
    {
        // 是否有
        public bool Has;
        public int Head;
        public string Name;
        
        public const uint Sid = 31;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out Has);
            UnPackAuxiliary.Read(stream, out uint var0);
            Head = (int)var0;
            UnPackAuxiliary.Read(stream, out Name);
        }
    }
    
    // 好友在线状态改变
    public struct NoticeFriendOnlineP : IUnPackable
    {
        public long FriendId;
        public bool Online;
        
        public const uint Sid = 32;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out ulong var0);
            FriendId = (long)var0;
            UnPackAuxiliary.Read(stream, out Online);
        }
    }
    
    public enum PhoneEnum
    {
        GetPhoneP,
        GetPhoneRecordsP,
        DeleteContactP,
        NoticeBeDeleteP,
        AddBlackListP,
        AddContactP,
        RepAddContactRepP,
        NoticeRepAddP,
        CallPlayerP,
        NoticeCallP,
        NoticeReplyCallP,
        NoticeAskQuestionP,
        NoticeAnswerP,
        NoticeSpeakP,
        NoticeVoiceInfoP,
        NoticeHangUpP,
        SearchByIdP,
        NoticeFriendOnlineP,
    }
}
